package dao;

import java.io.Serializable;
import java.util.List;

import modelo.Menu;
import modelo.Servicioadicionalxsalon;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

import util.HibernateUtil;

public class MenuxSalonDao implements Serializable{

	private static final long serialVersionUID = 663731985695075652L;
	private Session session;
	SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
	
	public MenuxSalonDao() {
		super();
	}
	
	
	public List<Menu> obtenerMenus() {
        session=sessionFactory.openSession();
        
        Query query = session.createQuery("SELECT m FROM Menu m");
        List<Menu> m = query.list();
        
        session.close();
        
        return m;
}
	
//	public List<Menu> obtenerMenus() {
//		session=sessionFactory.openSession();
//		
////		Query query = session.createQuery("SELECT m FROM Menu m");
//		Criteria cr = session.createCriteria(Menu.class);
//		cr.add(Restrictions.eq("salon.idSalon", 4));
//		List<Menu> ca= cr.list();
//		session.close();
//		
//		return ca;
//	}
	
	public List<Menu> obtenerMenuxSalon(int idSalon) {
		session=sessionFactory.openSession();

//			Query query = session.createQuery("SELECT m FROM Menu m");
		Criteria cr = session.createCriteria(Menu.class);
		cr.add(Restrictions.eq("salon.idSalon", idSalon));
		List<Menu> ca= cr.list();
		session.close();

		return ca;
		}

}
